/* Copyright (C) 2005-2013, Unigine Corp. All rights reserved.
 *
 * File:    vertex_base_shading.h
 * Desc:    Base vertex shading shader
 * Version: 1.01
 * Author:  Alexander Zapryagaev <frustum@unigine.com>
 *
 * This file is part of the Unigine engine (http://unigine.com/).
 *
 * Your use and or redistribution of this software in source and / or
 * binary form, with or without modification, is subject to: (i) your
 * ongoing acceptance of and compliance with the terms and conditions of
 * the Unigine License Agreement; and (ii) your inclusion of this notice
 * in any version of this software that you use or redistribute.
 * A copy of the Unigine License Agreement is available by contacting
 * Unigine Corp. at http://unigine.com/
 */

#ifndef __VERTEX_BASE_SHADING_H__
#define __VERTEX_BASE_SHADING_H__

/******************************************************************************\
*
* Environment light
*
\******************************************************************************/

/*
 */
half3 getEnvironment(half3 direction) {
	return max(s_environment[0].xyz -
		s_environment[1].xyz * direction.y +
		s_environment[2].xyz * direction.z +
		s_environment[3].xyz * direction.x +
		s_environment[4].xyz * (direction.x * direction.y) +
		s_environment[5].xyz * (direction.y * direction.z) +
		s_environment[6].xyz * (direction.z * direction.x) +
		s_environment[7].xyz * (direction.z * direction.z * 3.0f - 1.0f) +
		s_environment[8].xyz * (direction.x * direction.x - direction.y * direction.y),0.0f);
}

/*
 */
half3 getLightEnvironment(half3 direction) {
	return max(s_light_environment[0].xyz -
		s_light_environment[1].xyz * direction.y +
		s_light_environment[2].xyz * direction.z +
		s_light_environment[3].xyz * direction.x +
		s_light_environment[4].xyz * (direction.x * direction.y) +
		s_light_environment[5].xyz * (direction.y * direction.z) +
		s_light_environment[6].xyz * (direction.z * direction.x) +
		s_light_environment[7].xyz * (direction.z * direction.z * 3.0f - 1.0f) +
		s_light_environment[8].xyz * (direction.x * direction.x - direction.y * direction.y),0.0f);
}

#endif /* __VERTEX_BASE_SHADING_H__ */
